package com.happy.xiao.consumer.callback.config;


import com.happy.xiao.common.rabbitmq.BaseMessageContainer;
import com.happy.xiao.consumer.callback.rabbitmq.ReliabilityConfirmListener;
import com.happy.xiao.consumer.callback.rabbitmq.ReliabilityDelayListener;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMqConsumer extends BaseMessageContainer {


    // TODO ------------------------------------------------------------------------------------------------------------
    // TODO 可靠性队列

    @Autowired
    ReliabilityDelayListener reliabilityDelayListener;   // 延时队列

    @Autowired
    ReliabilityConfirmListener reliabilityConfirmListener; // 确认队列

    /**
     * 延时队列   的消费者监听
     *
     * @param checkDeadRealQueue
     * @return
     */
    @Bean(name = "checkRealContainer")
    public SimpleMessageListenerContainer checkRealContainer(@Qualifier("checkDeadRealQueue") Queue checkDeadRealQueue) {
        return createContainer(reliabilityDelayListener, checkDeadRealQueue);
    }

    /**
     * 消费消息确认队列  的消费者监听
     *
     * @param checkConfirmQueue
     * @return
     */
    @Bean(name = "checkConfirmContainer")
    public SimpleMessageListenerContainer checkConfirmContainer(@Qualifier("checkConfirmQueue") Queue checkConfirmQueue) {
        return createContainer(reliabilityConfirmListener, checkConfirmQueue);
    }

    // TODO ------------------------------------------------------------------------------------------------------------

}
